﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RobotCtrl;
using RobotView;

namespace TestConsole
{
    public partial class Form1 : Form
    {
        #region members
        private RobotConsole rc;
        #endregion

        #region constructor & destructor
        public Form1()
        {
            InitializeComponent();

            rc = new RobotConsole();
            consoleView1.RobotConsole = rc;
            // consoleView2.RobotConsole = rc;

            rc[Switches.Switch1].SwitchStateChanged += SwitchStateChanged;
            rc[Switches.Switch2].SwitchStateChanged += SwitchStateChanged;
            rc[Switches.Switch3].SwitchStateChanged += SwitchStateChanged;
            rc[Switches.Switch4].SwitchStateChanged += SwitchStateChanged;

        }
        #endregion

        private void ledView1_Click(object sender, EventArgs e)
        {

        }

        #region methods
        void SwitchStateChanged(object sender, SwitchEventArgs e)
        {
            Switches swi = e.Swi; // Event-Quelle
            bool switchEnabled = e.SwitchEnabled;

            int iSwi = (int)swi;
            Leds led = (Leds)iSwi;

            rc[led].LedEnabled = switchEnabled;

            // Alternative: rc[(Leds)(int)e.Swi].LedEnabled = e.SwitchEnabled;
        }
        #endregion
    }
}